<?php

include_once("./_common.php");
include_once ("./admin.head.php");


$w = $_GET['w'];
$id = $_GET['id'];
if($w == "u") {
	$sql = "select * from manage_list where mn_id = $mn_id";
	$rst = sql_query($sql);
	$write = mysql_fetch_assoc($rst);
	$title = "가맹점 리스트 수정";
	//print_r2($write);
} else {
	$w = "";
	$title = "가맹점 리스트 추가";
}

?>
<style>
	#csshelp1 { border:0px; background:#FFFFFF; padding:6px; }
	#csshelp2 { border:2px solid #BDBEC6; padding:0px; }
	#csshelp3 { background:#F9F9F9; padding:6px; width:200px; color:#222222; line-height:120%; text-align:center; }
	
	div.input_wrap {width:700px;margin:0 auto;}
	table.input_table {margin-top:20px;width:688px;border:1px solid #d9d9d9;}
	table.input_table tr {height:36px;}
	table.input_table th {background-color:#f9f9f7;border-top:1px solid #d9d9d9;border-right:1px solid #d9d9d9;text-align:left;padding-left:8px;font-weight:normal}
	table.input_table td {padding-left:10px;border-top:1px solid #d9d9d9;}
	div.input_btn {width:698px;text-align:center;margin-top:20px}
	
	.input_txt {border:1px solid #abadb3}
	th.col3_line {border-left:1px solid #d9d9d9}
</style>

<?=subtitle($title);?>

<div class="input_wrap">
	<br />
	<form action="./manage_list_update.php?bo_table=mg_list" method="post" id="fregister" name="fregister" enctype="multipart/form-data">
			<input type="hidden" name="w" value="<?php echo $w;?>" />
			<input type="hidden" name="mn_id" value="<?php echo $mn_id;?>" />
			<input type="hidden" name="area_name" value="<?php echo $area_name;?>" />
			
			<table class="input_table" cellpadding="0" cellspacing="0" border="0">
			<colgroup>
			<col width="118px" />
			<col width="" />
			<col width="118px" />
			<col width="" />
			</colgroup>
			<tr>
			<th style="border-top:none;">지역선택</th>
			<td colspan="3" style="border-top:none;">
				<select name="area_id" class="a_area input_txt">
				<?php if($write['area_id']==""){?>
				<option value="">지역선택</option>
				<?php }
				$sqla = "select * from area_list order by area ASC";
				$rsta = sql_query($sqla);
				while($rowa = mysql_fetch_assoc($rsta)) {
					$lista[] = $rowa;
				}
				for($i = 0; $i < count($lista); $i += 1) {
				?>
				<?php if (  $write['area_id'] == $lista[$i]['id'] ){
					$area_name = $lista[$i]['area'];
					$opt = "selected";
				 }else{
					$opt = "";
				}?>
				<option value="<?php echo $lista[$i]['id']?>" <?php echo $opt ?>><?php echo $lista[$i]['area']?></option>
				
				<?
				} ?>
				</select>
				
			</td>
			</tr>
			<tr>
				<th>가맹점명</th>
				<td colspan="3">
					<input type="text" name="mn_name" size="50" maxlength="15" class="mn_name_txt" style="margin-right:5px" value="<?php echo $write['mn_name']?>" id="datepicker">
				</td>
			</tr>
			<tr>
				<th>가맹점주소</th>
				<td colspan="3">
				<p>
				<?php
					if($write['mn_zip']){
						$strTok_zip = explode('-', $write['mn_zip']);
						$zip1 = $strTok_zip[0];
						$zip2 = $strTok_zip[1];
					}else{
						$zip1 = '';
						$zip2 = '';
					}
						
				?>
				<input type="text" id="a_zip1" name="a_zip1" size="5" maxlength="3" class="a_zip1 input_txt" title="우편번호 앞자리" value="<?php echo $zip1 ?>" />
				-
				<input type="text" id="a_zip2" name="a_zip2" size="5" maxlength="3" class="a_zip2 input_txt" title="우편번호 뒷자리" value="<?php echo $zip2 ?>" />
	
				<a href="#" class="win_zip_find" onclick="return false;"><img src="./img_btn/zip_btn.gif" class="zip_imgj" style="vertical-align:bottom" alt="우편번호검색" /></a>
				</p>
				<script>
				$(".zip_imgj").click(function() {
					window.open("http://augustin.co.kr/adm/adm_new/zip.php?frm_name=fregister&amp;frm_zip1=a_zip1&amp;frm_zip2=a_zip2&amp;frm_addr1=a_addr1&amp;frm_addr2=a_addr2","주소찾기","width=600px,height=500px,menubar=no,toolbar=no,location=no,scrollbars=yes,status=no")
				});
				</script>
				<?php
					$strTok_addr = explode('  ', $write['mn_addr']);
				?>
				<p class="guide"><input type="text" id="a_addr1" name="a_addr1" size="60" class="a_addr1 input_txt" title="주소" value="<?php echo $strTok_addr[0] ?>" /></p>
	
				<p class="guide">
					<input type="text" id="a_addr2" name="a_addr2" size="60" class="a_addr2 input_txt" title="상세주소" value="<?php echo $strTok_addr[1] ?>" />
				</p>
				</td>
			</tr>
			<tr>
				<th>가맹점연락처</th>
				<td colspan="3">
					<?php
						$strTok = explode('-', $write['mn_phone']);
					?>
					<input type="text" name="mn_phone1" size="4" maxlength="8" class="mn_phone_txt" style="margin-right:5px" value="<?php echo $strTok[0] ?>" >
					ㅡ&nbsp;
					<input type="text" name="mn_phone2" size="5" maxlength="8" class="mn_phone_txt" style="margin-right:5px" value="<?php echo $strTok[1] ?>">
				         ㅡ&nbsp;
					<input type="text" name="mn_phone3" size="5" maxlength="8" class="mn_phone_txt" style="margin-right:5px" value="<?php echo $strTok[2] ?>">
				</td>
			</tr>
			<tr>
				<th>영업시간</th>
				<td colspan="3">
					<input type="text" name="mn_hours" size="60" maxlength="100" class="mn_hours_txt" style="margin-right:5px" value="<?php echo $write['mn_hours']?>" >
				</td>
			</tr>
			<tr>
				<th>오픈여부</th>
				<td colspan="3">
					<div class="day_select">
					<input type="radio"  value="오픈" name='mn_open' <?php echo $write['open_type'] == "오픈" ? "checked" : ""?>>오픈</input>
					<input type="radio" value="예정" name='mn_open' <?php echo $write['open_type'] == "예정" ? "checked" : ""?>>예정</input>
					</div>
				</td>
			</tr>
			
		</table>
		<div class="input_btn">
		    <?php
		     
		    ?>
			<input type="image" src="./img_btn/save_btn.gif" />
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			<img src="./img_btn/list_btn.gif" class="list_btn" style="cursor:pointer" />
		</div>
	</form>
</div>


<script>
$(".list_btn").click(function() {
	location.href = "./manage_list.php?bo_table=mg_list";
});
</script>